import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '门店名称',
    align: "center",
    dataIndex: 'storeName'
  },
  {
    title: 'POI名称',
    align: "center",
    dataIndex: 'poiName'
  },
  {
    title: '门店地址',
    align: "center",
    dataIndex: 'storeAddress'
  },
  {
    title: '代理商',
    align: "center",
    dataIndex: 'agent'
  },
  {
    title: '系统',
    align: "center",
    dataIndex: 'channal'
  },
  {
    title: '销售区域',
    align: "center",
    dataIndex: 'salesDepartment'
  },
  {
    title: '省',
    align: "center",
    dataIndex: 'province'
  },
  {
    title: '市',
    align: "center",
    dataIndex: 'city'
  },
  {
    title: '区',
    align: "center",
    dataIndex: 'district'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "门店名称",
    field: 'storeName',
    component: 'JInput',
    //colProps: {span: 6},
  },
  {
    label: "销售区域",
    field: 'salesDepartmentId',
    component: 'JTreeSelect',
    componentProps: {
      dict: "gbt_sales_department,name,id",
      pidValue: "0",
    },
    //colProps: {span: 6},
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '门店名称',
    field: 'storeName',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入门店名称!' },
      ];
    },
  },
  {
    label: '门店地址',
    field: 'storeAddress',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入门店地址!' },
      ];
    },
  },
  {
    label: '代理商',
    field: 'agentId',
    component: 'JSearchSelect',
    componentProps: {
      //字典code配置，通过 demo,name,id 表名,名称,值的方式
      dict: 't_offline_agent,name,id',
      //是否异步加载
      async: true,
      //当async设置为true时有效，表示异步查询时，每次获取数据的数量，默认10
      pageSize:10
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入代理商!' },
      ];
    },
  },
  {
    label: '系统',
    field: 'channal',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: false, message: '请输入所属系统!' },
      ];
    },
  },
  {
    label: '销售区域',
    field: 'salesDepartmentId',
    component: 'JTreeSelect',
    componentProps: {
      dict: "gbt_sales_department,name,id",
      pidValue: "0",
    },
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入销售区域!' },
      ];
    },
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];

// 高级查询数据
export const superQuerySchema = {
  storeName: { title: '门店名称', order: 0, view: 'text', type: 'string', },
  storeAddress: { title: '门店地址', order: 1, view: 'text', type: 'string', },
  salesDepartmentId: { title: '销售区域', order: 2, view: 'sel_tree', type: 'string', dict: 'gbt_sales_department,name,id', pidValue: '0', },
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
